<template>
    <el-card shadow="never" style="border: 0;">
        {if $config.route[2]=='edit'}
        <template #header>
            <el-alert
                    type="warning"
                    show-icon>
                非调试模式下，提交后请清空缓存才能生效！
            </el-alert>
        </template>
        {/if}
        <yun-form
                v-if="columns"
                :data="data"
                ref="yunform"
                :columns="columns">
            <template #default>
                {:token_field()}
            </template>
            <template #groupids="item">
                <el-form-item label="{:__('所属组别')}:" prop="groupids">
                    <el-select :disabled="disabled" placeholder="请选择{:__('所属组别')}" multiple v-model="item.rows.groupids" :clearable="true" style="width: 100%">
                        {foreach $groupdata as $key=>$value}
                        <el-option key="{$value.id}" label="{:str_replace('&amp;','&',$value.name)}" value="{$value.id}"></el-option>
                        {/foreach}
                    </el-select>
                </el-form-item>
            </template>
            <template v-slot:third_id="{rows}">
                <el-form-item label="绑定微信:">
                    <third :value="rows.third_id" :selectable="true" @change="changValue"></third>
                </el-form-item>
            </template>
        </yun-form>
    </el-card>
</template>
<script>
    import form from "@components/Form.js";
    import third from "@components/Third.js";
    export default{
        components:{'YunForm':form,'Third':third},
        data:{
            data:Yunqi.data.row || {},
            disabled:false,
            columns:''
        },
        onLoad:function (query){
            let ids=query.ids;
            this.columns=[
                {field: 'id',title: __('ID'),edit:'hidden'},
                {field: 'username', title: __('用户名'),edit:(ids==1)?'readonly':'text',rules:'required'},
                {field: 'password', title: __('密码'),edit:'password',rules:(Yunqi.config.route[2]=='add')?'required':''},
                {field: 'nickname', title: __('昵称'),edit:'text',rules:'required'},
                {field: 'mobile', title: __('手机号'),edit:'text',rules:'required;mobile'},
                {
                    field: 'groupids',
                    title: __('所属组别'),
                    edit:{form:'slot',value:[]},
                    rules:'required'
                },
                {field: 'third_id', title: __('绑定微信'),edit:Yunqi.data.thirdLogin?'slot':false},
                {field: 'status', title: __('状态'),searchList: {'normal': __('正常'),'hidden': __('隐藏')},edit:{form:'radio',value:'normal'}}
            ];
            if(ids==1){
                this.disabled=true;
            }
        },
        onShow:function (){

        },
        methods: {
            changValue:function (e){
                this.$refs.yunform.setValue('third_id',e);
            }
        }
    }
</script>
<style>

</style>
